/*
  Copyright 2006 by Sean Luke
  Licensed under the Academic Free License version 3.0
  See the file "LICENSE" for more information
 */

package ec.app.deferEvalCoevolve1;

import ec.Fitness;
import ec.EvolutionState;
import ec.simple.SimpleDefaults;
import ec.util.*;
import java.io.*;

/*
 * SimpleFitnessVar2.java
 *
 * Created: Tue Aug 10 20:10:42 1999
 * By: Sean Luke
 */

/**
 * A simple default fitness, consisting of a single floating-point value where
 * fitness A is superior to fitness B if and only if A > B. Fitness values may
 * range from (-infinity,infinity) exclusive -- that is, you may not have
 * infinite fitnesses.
 * 
 * <p>
 * Some kinds of selection methods require a more stringent definition of
 * fitness. For example, FitProportionateSelection requires that fitnesses be
 * non-negative (since it must place them into a proportionate distribution).
 * You may wish to restrict yourself to values in [0,1] or [0,infinity) in such
 * cases.
 * 
 * <p>
 * <b>Default Base</b><br>
 * simple.fitness
 * 
 * @author Sean Luke
 * @version 1.0
 */

public class SimpleFitnessVar2 extends SimpleFitnessVar1 {

	public double altFit = Double.NEGATIVE_INFINITY;

	public void setAltFit(final double newAlt) {
		altFit = newAlt;
	}

	public void improveAltFit(final double newAlt) {
		if (newAlt > altFit)
			altFit = newAlt;
		return;
	}

	public double getAltFit() {
		return altFit;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * ec.app.deferEvalCoevolve1.SimpleFitnessVar1#fitnessToStringForHumans()
	 */
	public String fitnessToStringForHumans() {
		return FITNESS_PREAMBLE + fitness() + "\taltFit: " + altFit
				+ "\tevals: " + getEvalCount();
	}

}
